package com.iterative.system.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.iterative.common.persistence.HibernateDao;
import com.iterative.system.entity.RolePermission;

@Repository
public class RolePermissionDao extends HibernateDao<RolePermission, Long>{

	public List<Long> findPermissionIds(Long roleId) {
		String hql="select rp.permissionId from RolePermission rp where rp.roleId=?0";
		Query query= createQuery(hql, roleId);
		return query.list();
	}

	public void deleteRP(Long roleId, Long permissionId) {
		String hql="delete RolePermission rp where rp.roleId=?0 and rp.permissionId=?1";
		batchExecute(hql, roleId,permissionId);
	}

	
}
